﻿<html>
    <head>
        <title></title>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
        <script type="text/javascript">

            var token = "";
            $.get('/amba.kvs/token', function (result) {
                token = $.trim(result);
            });
         
            function Load() {
                var key = $("#load input[name='key']").val();
               
                $.ajax({
                    url: '/amba.kvs/get',
                    type: "POST",
                    data: { key: key, __RequestVerificationToken: token },
                    cache: false
                }).done(function (result) {
                    $("#load input[name='value']").val(result);
                });
                return false;
            }
            
            function Save() {
                var key = $("#save input[name='key']").val();
                var value = $("#save input[name='value']").val();
                $.ajax({
                    url: '/amba.kvs/set',
                    type: "POST",
                    data: { key: key, value: value, __RequestVerificationToken: token },
                    cache:false
                }).done(function() {
                    alert("Saved");
                });
                return false;
            }
        </script>
    </head>
    <body>
        <h1>Save</h1>
        <form id="save">
            <table>
                <tr>
                    <td>Key:</td> 
                    <td><input type="text" name="key"/></td>
                </tr>
                <tr>
                    <td>Value: </td>
                    <td>
                        <input type="text" name="value"/>
                    </td>
                </tr>
            </table>
            <div>
                <button onclick="Save(); return false;">Save</button>
            </div>
        </form>
        <h1>Load</h1>
        <form id="load">
            <table>
                <tr>
                    <td>Key:</td> 
                    <td><input type="text" name="key"/></td>
                </tr>
                <tr>
                    <td>Value: </td>
                    <td>
                        <input readonly="readonly" type="text" name="value"/>
                    </td>
                </tr>
            </table>
            <div>
                <button onclick="Load(); return false;">Load</button>
            </div>
        </form>
    </body>
</html>